package com.dynabook.ems.model.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.util.List;

/**
 * BOM编辑请求DTO
 */
@Data
@ApiModel(value = "BOM编辑请求", description = "编辑BOM详情的请求参数")
public class BomEditRequest {
    @ApiModelProperty(value = "BOM主键id", example = "1", required = true)
    @NotNull(message = "BOM主键id不能为空")
    private Long id;
    /**
     //     * BOM编号
     //     */
//    @ApiModelProperty(value = "BOM编号", example = "B25060001", required = true)
//    @NotBlank(message = "BOM编号不能为空")
//    private String bomNum;
//

//    @ApiModelProperty(value = "BOM版本", example = "01", required = true)
//    @NotBlank(message = "BOM版本不能为空")
//    private String version;
    /**
     * 成品型号前缀
     */
    @ApiModelProperty(value = "成品型号前缀", example = "PNL13N-AAA11",required = true)
    @Pattern(regexp = "^(?i)(P|A).{11}$", message = "成品型号前缀必须是12位字符串，并且以P或A开头（不区分大小写）")
    private String productNamePrefix;

    /**
     * 成品型号后缀
     */
    @ApiModelProperty(value = "成品型号后缀", example = "N01",required = true)
    @NotBlank(message = "成品型号后缀不能为空")
    private String productNameSuffix;

    /**
     * 成品名称
     */
     @ApiModelProperty(value = "成品名称", example = "")
     @NotBlank(message = "成品名称不能为空")
    private String finishProductName;

    /**
     * 机型名称
     */
    @ApiModelProperty(value = "机型名称", example = "Pearl20", required = true)
    @NotBlank(message = "机型名称不能为空")
    private String machineName;

    /**
     * BOM详细信息列表
     */
    @ApiModelProperty(value = "BOM详细信息列表", required = true)
    @NotEmpty(message = "BOM详细信息不能为空")
    private List<BomDetailEditItem> bomDetails;
    
    /**
     * BOM详细项编辑
     */
    @Data
    @ApiModel(value = "BOM详细项编辑", description = "BOM中的具体零部件编辑信息")
    public static class BomDetailEditItem {
        
        /**
         * 详情ID（必须，用于标识要编辑的记录）
         */
        @ApiModelProperty(value = "详情ID", example = "1234567890", required = false)
        private Long id;
        
        /**
         * 样品型号
         */
        @ApiModelProperty(value = "样品型号", example = "GDM460010306", required = true)
        @NotBlank(message = "样品型号不能为空")
        private String modelType;
        
        /**
         * 样品名称
         */
        @ApiModelProperty(value = "样品名称", example = "CPU Ultra 7 258V", required = true)
        @NotBlank(message = "样品名称不能为空")
        private String modelName;
        
        /**
         * 数量
         */
        @ApiModelProperty(value = "数量", example = "1", required = true)
        @NotNull(message = "数量不能为空")
        private Integer modelNumber;
        
        /**
         * 单位
         */
        @ApiModelProperty(value = "单位", example = "P", required = true)
        @NotBlank(message = "单位不能为空")
        private String modelUnit;
        
        /**
         * 类型
         */
        @ApiModelProperty(value = "类型", example = "P", required = true)
        @NotBlank(message = "类型不能为空")
        private String modelCategory;
        
        /**
         * 备注
         */
        @ApiModelProperty(value = "备注", example = "")
        private String remark;
    }
}